home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************\
- * Header Files
- \******************************************************************************/
-
- #include <Events.h>
- #include <Memory.h>
- #include <Windows.h>
- #include "AnimCursor.h"
- #include "ShowCursor.h"
- #include "CursWindTkl.h"
- #include "WindowTkl.h"
-
-
- /******************************************************************************\
- * Constants & Macros
- \******************************************************************************/
-
- #define cursWindID 128 //Resource ID of Cursor window
-
-
- /******************************************************************************\
- * Function Prototypes
- \******************************************************************************/
-
- void ProgressCursor (void);
- void BeachBallCursor (void);
-
-
- #pragma segment Main
- /******************************************************************************\
- * CreateCursWind - Create a new Cursor window
- *
- * CreateCursWind creates a new Cursor window and returns a pointer to it. The
- * window is set to the current port and is centered on the screen. If there
- * isn’t enough memory for a new window, gApplErr is set to memFulErr. If the
- * window’s resource couldn’t be found, gApplErr is set to appDmgErr. In both
- * cases, null is returned.
- \******************************************************************************/
-
- WindowPtr
- CreateCursWind ()
- {
- Ptr WindStore; //-> Window record storage
- WindowPtr CursWind; //-> New Cursor window
- Point CentPoint; //Top-left corner of window to center it
- ControlHandle TheControl; //=> Button controls
-
- WindStore = (Ptr) null;
- CursWind = (WindowPtr) null;
- if ((WindStore = NewPtr ((Size) sizeof (WindowRecord))) == (Ptr) null)
- {
- gApplErr = memFulErr;
- goto Abort;
- }
- if ((CursWind = (WindowPtr) GetNewWindow (cursWindID, WindStore,
- (WindowPtr) -1)) == (WindowPtr) null)
- {
- if (MemError () != noErr)
- gApplErr = memFulErr;
- else
- gApplErr = appDmgErr;
- goto Abort;
- }
- ((WindowPeek) CursWind)->windowKind = cursWindKind;
- SetWindSize ((WindowPtr) CursWind);
- SetPort ((GrafPtr) CursWind);
- CentPoint.h = ((qd.screenBits.bounds.right - qd.screenBits.bounds.left) - (CursWind->portRect.
- right - CursWind->portRect.left) + qd.screenBits.bounds.left) >> 1;
- CentPoint.v = ((qd.screenBits.bounds.bottom - qd.screenBits.bounds.top) - (CursWind->portRect.
- bottom - CursWind->portRect.top) + qd.screenBits.bounds.top) / 3;
- MoveWindow ((WindowPtr) CursWind, CentPoint.h, CentPoint.v, true);
- if ((TheControl = GetNewControl (128, (WindowPtr) CursWind)) == (ControlHandle) null)
- {
- gApplErr = appDmgErr;
- goto Abort;
- }
- (**TheControl).contrlRfCon = 0L;
- if ((TheControl = GetNewControl (129, (WindowPtr) CursWind)) == (ControlHandle) null)
- {
- gApplErr = appDmgErr;
- goto Abort;
- }
- (**TheControl).contrlRfCon = 1L;
- ShowWindow ((WindowPtr) CursWind);
- return CursWind;
-
- Abort:
- if (CursWind!= (WindowPtr) null)
- CloseWindow ((WindowPtr) CursWind);
- if (WindStore != (Ptr) null)
- DisposPtr (WindStore);
- return (WindowPtr) null;
- }
-
-
- #pragma segment Main
- /******************************************************************************\
- * DrawCursWind - Draw into a Cursor window
- *
- * DrawCursWind draws into the Cursor window specified by CursWind.
- \******************************************************************************/
-
- void
- DrawCursWind (CursWind)
- WindowPtr CursWind; //-> Cursor window to draw <>
- {
- DrawControls ((WindowPtr) CursWind);
- }
-
-
- #pragma segment Main
- /******************************************************************************\
- * ContentCursWind - Handle a click in the contents of a Cursor window
- *
- * ContentCursWind handles a click in the content region of the window pointed to
- * by CursWind.
- \******************************************************************************/
-
- void
- ContentCursWind (TheEvent, CursWind)
- EventRecord *TheEvent; //-> Event record that recorded the click >>
- WindowPtr CursWind; //-> Cursor window to draw <>
- {
- GrafPtr CurrPort; //-> Current GrafPort
- Point ClickPoint; //Coordinate of mouse click in window coords
- ControlHandle TheControl; //=> Clicked control
- short ThePart; //Part number of clicked control part
-
- GetPort (&CurrPort);
- SetPort ((GrafPtr) CursWind);
- ClickPoint = TheEvent->where;
- GlobalToLocal (&ClickPoint);
- ThePart = FindControl (ClickPoint, (WindowPtr) CursWind, &TheControl);
- if (ThePart != 0)
- {
- if (TrackControl (TheControl, ClickPoint, (ProcPtr) null))
- if ((**TheControl).contrlRfCon == 0L)
- ProgressCursor ();
- else if ((**TheControl).contrlRfCon == 1L)
- BeachBallCursor ();
- }
- SetPort (CurrPort);
- }
-
-
- #pragma segment Main
- /******************************************************************************\
- * ProgressCursor - Show a progress cursor
- *
- * ProgressCursor shows a progress cursor. Nothing really happens during this
- * time, it’s just wasting it.
- \******************************************************************************/
-
- static void
- ProgressCursor ()
- {
- short Min; /* Minimum value of Index */
- short Max; /* Maximum value of Index */
- short Index; /* Index of values */
- AnimCursHnd AnimCurs; /* => Animated cursor list */
- long TheCount; /* Stuff for delay */
-
- if (gEnvirons.hasColorQD)
- AnimCurs = GetAnimCurs (1000);
- else
- AnimCurs = GetAnimCurs (150);
- Min = 0;
- Max = 100;
- for (Index = Min; Index <= Max; Index++)
- {
- AnimateProgCurs (AnimCurs, Min, Max, Index);
- Delay (3, &TheCount);
- }
- DisposeAnimCurs (AnimCurs);
- }
-
-
- #pragma segment Main
- /******************************************************************************\
- * BeachBallCursor - Show a BeachBall cursor
- *
- * BeachBallCursor shows a beachball cursor. The beachball animates until the
- * user clicks the mouse button.
- \******************************************************************************/
-
- static void
- BeachBallCursor ()
- {
- short Index;
- AnimCursHnd AnimCurs;
- long TheCount;
- EventRecord TheEvent;
- short StillGoing;
-
- if (gEnvirons.hasColorQD)
- AnimCurs = GetAnimCurs (2000);
- else
- AnimCurs = GetAnimCurs (128);
- StillGoing = true;
- while (StillGoing)
- {
- if (EventAvail (everyEvent, &TheEvent))
- if (TheEvent.what == mouseDown || TheEvent.what == app4Evt)
- StillGoing = false;
- AnimateCurs (AnimCurs);
- Delay (3, &TheCount);
- }
- DisposeAnimCurs (AnimCurs);
- }
-
-
- #pragma segment Main
- /******************************************************************************\
- * CloseCursWind - Close a Cursor window
- *
- * CloseCursWind closes the Cursor window specified by CursWind.
- \******************************************************************************/
-
- void
- CloseCursWind (CursWind)
- WindowPtr CursWind; //-> Cursor window to close <>
- {
- CloseWindow ((WindowPtr) CursWind);
- DisposPtr ((Ptr) CursWind);
- }
-